Serial port communications:
4.1. Q - How is the serial port I/O implemented?
A - Serial I/O is implemented as follows:
Transmit and receive I/O is done via interrupts.
When a character is to be sent, it is put on a circular buffer and the TXI bit is set.
This interrupts the system and the interrupt routine puts the character in the TXREG.
When transmission is complete, the MCU interrupts again and another character is put
in the TXREG. When the circular buffer is empty, the system waits for more input.
The transmit circular buffer size(TX_BUFF_SIZE) is defined in serial.h.
By default it set to 70 characters. For some debugging situations, it might be
necessary to increase this number.
When a character is received, it is put on the receive message queue and is read via
the OS_WaitMsg(MSG_GOT_SERIAL,,,,) function in the serial.c source file.
4.2. Q - Where do I change the default baud rate?
A - The BAUD rate is changed in the sysconfig.h file.
This will require a re-compile to take effect.
4.3. Q - Can RTS/CTS handshaking be disabled?
A - Currently the serial I/O functions rely on RTS/CTS handshaking to properly work. In any
system, it is always best to know when a receiver can accept more data. Without RTS/CTS
we would blindly send data and as a result, some data would get lost.
4.4. Q - What do the different USARTx functions do?
A - All serial I/O functions are defined in the usartutils.c source file.
Below is a brief description of the functions.
USARTPut - This is the low level function that sends a character to the
serial port. This function is not normally used. Instead the
USARTPutChar and USARTPutString are used.
USARTPutChar - Send a character to the serial port. Possibly block.
USARTPutString - Send a string to the serial port. Possibly block.
This function returns a pointer to the part of the string that was
not sent or NULL if everything was sent.
USARTPutByte - This function sends a BYTE to the serial port and optionally,
puts brackets around the number.
The BYTE is printed as a 2 digit hex number.
The number could look like:
[00] or 00
USARTPutWord - This function sends a BYTE to the serial port and optionally,
puts brackets around the number.
The BYTE is printed as a 4 digit hex number.
The number could look like:
[0000] or 0000